package engine

type SimpleEngine struct {
}

func (e SimpleEngine) Run(seeds ...Request) {
	var requests []Request
	//初始化一些二种子给队列，
	for _, r := range seeds {
		requests = append(requests, r)
	}
	//对于队列中的种子中url给抓取器，抓取器获得页面给种子中的解析器，解析器解析得到request ，继续加入队列。子子孙孙无穷匮也
	for len(requests) > 0 {
		r := requests[0]
		requests = requests[1:]
		parserFunc, err := Worker(r)
		if err != nil {
			continue
		}
		//语法糖，当像另外一个数组中追加其中一个数组的元素。（数组合并）时将需要追加的数组后面加...
		requests = append(requests, parserFunc.Request...)
		//for _, item := range parserFunc.Items {
		//	log.Printf("%v", item)
		//}
	}
}
